<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>果然FruitC</title>
        <meta content="telephone=no" name="format-detection" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <meta name="renderer" content="webkit">
		<link href="${ctx }/shop/css/amazeui.min.css" rel="stylesheet" type="text/css" />
		<link href="${ctx }/shop/css/style.css" rel="stylesheet" type="text/css" />
		<style>
			.order-state li{
				width:20%;
			}
			.c-comment-list p{
				font-size:1.5rem;
			}
			.comment{
				position:absolute;right:10px;z-index:10;top:-30px;
				color:#7b5454;
			}
			.uncomment{
				color:#e21010;
			}
		</style>
	</head>
	<body>
		<header data-am-widget="header" class="am-header am-header-default sq-head ">
			<div class="am-header-left am-header-nav">
				<a href="${ctx}/orderPage" class="">
					<i class="am-icon-chevron-left"></i>
				</a>
			</div>
			<h1 class="am-header-title">
  	            <a  class="">订单详情</a>
            </h1>
	    </header>
	    <div style="height: 49px;"></div>
	    <div class="d-infor">
	    	<p class="text"><i class="iconfont">&#xe606</i>
	    	<span>
		    	<c:choose>
		    		<c:when test="${order.status_==0 }">订单待付款</c:when>
		    		<c:when test="${order.status_==1 }">订单已付款，等待发货</c:when>
		    		<c:when test="${order.status_==2 }">订单已收货，等待评价</c:when>
		    		<c:when test="${order.status_==3 }">订单已完成</c:when>
		    		<c:when test="${order.status_==4 }">订单已发货，等待收货</c:when>
		    	</c:choose>
	    	</span></p>
	    	<p class="price">总价：￥${order.price_}</p>
	    </div>
	    <div class="c-com-btn">
   			 <c:choose>
	    		<c:when test="${order.status_==0 }"><a href="${ctx}/pay?id=${order.id}" class="topay">立即支付</a><a href="javascript:cancelOrder('${order.id}')" class="canelpay">取消订单</a></c:when>
	    		<c:when test="${order.status_==4 }"><a href="javascript:receive('${order.id}')" class="topay">确认收货</a></c:when>
	    		<c:when test="${order.status_==2 }"><a href="#oooo" class="topay">立即评价</a></c:when>
	    		<c:when test="${order.status_==3 }"></c:when>
	    		<c:when test="${order.status_==1 }"><a href="javascript:quick()" class="topay">催发货</a></c:when>
	    	</c:choose>
			
		</div>
		<div class="clear"></div>
		<ul class="order-state">
			<li>
				<span <c:if test="${order.status_==0 }">class="current"</c:if>><i class="iconfont">&#xe607;</i></span>
				<p>付款</p>
				<div class="line"></div>
			</li>
			<li>
				<span <c:if test="${order.status_==1 }">class="current"</c:if>><i class="iconfont">&#xe608;</i></span>
				<p>待发货</p>
			</li>
			<li>
				<span <c:if test="${order.status_==4 }">class="current"</c:if> ><i class="iconfont">&#xe609;</i></span>
				<p>配送中</p>
				<div class="line"></div>
			</li>
			<li>
				<span <c:if test="${order.status_==2 }">class="current"</c:if> ><i class="iconfont">&#xe60a;</i></span>
				<p>待评价</p>
				<div class="line"></div>
			</li>
			<li>
				<span <c:if test="${order.status_==3 }">class="current"</c:if>><i class="iconfont">&#xe608;</i></span>
				<p>已完成</p>
			</li>
		</ul>
		<div class="clear"></div>
		<div class="c-comment">
			<span class="c-comment-num">商品详情</span>
		</div>
		<a id="oooo"></a>
		<div class="c-comment-list" style="border: 0; padding: 0;">
			<c:forEach var="record" items="${order.gifts }">
				<a class="o-con" style="">
	            	<div class="o-con-img" onclick="location.href='${ctx}/detail?id=${record.gift_id_ }'"><img src="${record.img_ }"></div>
	                <div class="o-con-txt">
	                	<p>${record.name_ }</p>
	                	<p class="price">￥${record.price_ }</p>
	                </div>
	            	<div class="o-con-much"> <h4>x${record.count_ }</h4></div>
	            </a>
	            <c:choose>
	            	<c:when test="${record.iscomment == 0 && order.status_==2}">
	            		<div style="position:relative;">
			           		 <a href="javascript:pingjia('${record.name_ }','${record.gift_id_ }','${record.id }')" id="${record.id }" class="comment uncomment" >去评价</a>
		           		 </div>
	            	</c:when>
	            	<c:when test="${record.iscomment == 1 && order.status_==2}">
	            		<div style="position:relative;">
			           		 <a  class="comment">已评价</a>
		           		 </div>
	            	</c:when>
	            	
	            </c:choose>
	            
			</c:forEach>
			
		</div>
		<ul class="orderdetail-text">
			<li>
				<span>红包抵扣</span>
				<i>￥${order.yhq_ }</i>
			</li>
			<li>
				<span>实付金额</span>
				<i style="color: #cb2527;">￥${order.price_ }</i>
			</li>
		</ul>
<!-- 		<div class="c-com-btn"> -->
<!-- 			<a href="" class="oncepay">再来一单</a> -->
<!-- 		</div> -->
		<div class="clear"></div>
		<div class="c-comment">
			<span class="c-comment-num">订单详情</span>
		</div>
		<div class="order-info">
			<p>订单编号：${order.id }</p>
			<p>订单时间：${order.create_time_.toString().substring(0,19)}</p>
			<p>收货人：${order.address.name_ }</p>
			<p>手机号码：${order.address.mobile_ }</p>
			<p>收货地址：${order.address.addr_ }</p>
			<c:if test="${order.status_==4  }">
			<p>快递单号：${order.logistics_number_}</p>
			</c:if>
			<p>备注信息：${order.remark_}</p>
			<c:if test="${order.status_==4  }">
				<p>物流信息：</p>
				<p id="detailInfo"></p>
			</c:if>
			
		</div>
		  <!--底部-->
 <div style="height: 55px;"></div>
	</body>
	<script src="${ctx }/shop/js/jquery-1.10.2.min.js"></script>
	<script src="${ctx }/shop/js/util.js"></script>
	<script>
	var status = "${order.status_==4}";
	window.onload = function(){
		if(status == "true"){
			sendReq("${ctx}/queryDelivery",{num:"${order.logistics_number_}"},function(data){
				$("#detailInfo").html(data.msg);
			});
		}
	}
		function pingjia(title,id,ordergiftid){
			hit_box_three(title,'take_btn','close_btn_all','确定','取消',function(text){
				sendReq("${ctx}/addComment",{id:id,text:text,oid:ordergiftid,orderid:"${order.id}"},function(data){
					$("#"+ordergiftid).removeClass("uncomment").text("已评价").attr("href",null);
					if($(".uncomment").length == 0){
						location.reload();
					}
				})
			});
		}
		
		function receive(id){
			hit_box_two('',"",'您确认要收货吗?','take_btn','close_btn_all','确定','取消',function(){
					sendReq("${ctx}/receive/"+id,{},function(data){
							if(data.status == true){
									location.reload();
							}
					})
			});
		}
		function quick(){
			hit_box_one('店家已经收到通知啦','','','我知道啦','');
		}
		
		function cancelOrder(id){
			hit_box_two('您确认要取消该订单吗?<br>',"优惠券将会退回到您的账户",'','take_btn','close_btn_all','确定','取消',function(){
				sendReq("${ctx}/cancelOrder/"+id,{},function(data){
						if(data.status == true){
								location.href="${ctx}/orderPage";
						}
				})
		});
		}
	</script>
<%@include file="../common/jsticket.jsp"%><!--静态包含-->  
</html>
